package com.glela.goods.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.glela.goods.model.Activity;
import com.glela.goods.model.ResponseSeckillList;

public interface ActivityMapper {

	int deleteByPrimaryKey(Long id);

	int insert(Activity record);

	int insertSelective(Activity record);

	Activity selectByPrimaryKey(Long id);

	int updateByPrimaryKeySelective(Activity record);

	int updateByPrimaryKey(Activity record);

	Activity selectIngByPrimaryKey(Long id);

	int subInventoryNumById(@Param("id") long id, @Param("quantity") int quantity);

	int subInventoryNumById(@Param("id") long id, @Param("quantity") int quantity,
			@Param("inventoryId") long inventoryId);

	/**
	 * APP端获取本店所有的type活动
	 * 
	 * @author 卫耀华
	 * @param storeId
	 * @param type
	 * @return
	 */
	List<Activity> selectActivityListByStoreId(@Param("storeId") int storeId, @Param("type") int type);

	/**
	 * APP端获取本店正在进行中的活动
	 * 
	 * @author 卫耀华
	 * @param storeId
	 * @return
	 */
	List<Activity> selectActivityListByStoreIdAndIng(@Param("storeId") int storeId, @Param("type") int type);

	/**
	 * 获得所有已经结束的活动
	 * 
	 * @author 卫耀华
	 * @return
	 */
	List<Activity> selectAllEndActivityList();

	/**
	 * 将活动设置为禁用，是否APP展示改为不展示
	 * 
	 * @author 卫耀华
	 * @param id
	 */
	void updateActivityDisabled(@Param("id") Long id);

	/**
	 * 获取一个状态是启用，在APP展示的活动
	 * 
	 * @author 卫耀华
	 * @param id
	 * @return
	 */
	Activity selectActivityByPrimaryKey(@Param("id") Long id);

	/**
	 * 查询正在进行的秒杀和预告的秒杀
	 * 
	 * @author 卫耀华
	 * @date 2016-12-27
	 * @param storeId
	 * @return
	 */
	List<Activity> selectMiaoShaActivityListByStoreId(@Param("storeId") int storeId);

	List<Activity> selectActivityByType(@Param("type") int type, @Param("startIndex") int startIndex,
			@Param("pageSize") int pageSize);

	/**
	 * 关闭订单
	 * 
	 * @param orderObjectId
	 * @return
	 */
	int updateOrderStatus(Long orderObjectId);

	/**
	 * 归还库存
	 * 
	 * @param orderObjectId
	 * @return
	 */
	int updateInventoryBack(Long orderObjectId);

	/**
	 * 福利社(新欲购)
	 * 
	 * @author 卫耀华
	 * @date 2017-02-07
	 * @return
	 */
	List<Activity> selectIngFuLiSheActivityList();

	/**
	 * 首页秒杀列表
	 * @return
	 */
	List<ResponseSeckillList> selectIndexSeckillActivity();

	List<ResponseSeckillList> selectMoreInfoSeckill(@Param("startIndex")int startIndex, @Param("pageSize")int pageSize);

	List<ResponseSeckillList> selectMoreInfoSeckillWait(@Param("startIndex")int startIndex, @Param("pageSize")int pageSize);

	Activity selectActivityWithNum(long activityId);

}